<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="ltr" lang="zh-CN">
<head>
<link rel="SHORTCUT ICON" href="<%=basePath%>images/system/favicon.ico">
<title>移动作业可视化管控平台</title>
<meta name="keywords" content="xjwrj" />
<meta name="description" content="xjwrj" />
<meta name="Language" content="zh-CN" />
<meta name="Copyright" content="xjwrj" />
<meta name="Designer" content="xjwrj" />
<meta name="Publisher" content="xjwrj" />
<meta name="Distribution" content="Global" />
<meta name="author" content="xjwrj" />
<meta name="robots" content="index,follow" />
<meta name="googlebot" content="index,follow,archive" />
<!-- <link href="css/main1.css" rel="stylesheet" type="text/css" /> -->
<script type="text/javascript" src="javascript/jquery/jquery.min.js"></script>
<script type="text/javascript" src="javascript/sha1/sha1.js"></script>

<style type="text/css">
body {
	position: relative;
	margin: 0;
	padding: 0;
}
.logingb {
	width: 707px;
	height: 382px;
	background: url(images/login/登录框背景.png);
	position: absolute;
	z-index: 1000;
	right: 0px;
	top: 30%;
}
input{
	border: 1px solid #12b0b1;
	padding: 0 0 0 5; 
	background-color: #036161;
	color: #dfdfdf;
	line-height: 30px;
	font-size: 12px;
	border-radius: 4px;
	height:30px;
	width:230px;
}
.subbut{height: 35px;line-height: 35px;
	position: absolute; top: 250px;left: 225px;
}
.subbut button{
	color:#fff;
	width:230px;
	border-radius:4px;
	background: rgb(49,192,45);
	cursor: pointer;
	outline: none;
	resize:none;
	border: none;
	height: 28px;
	line-height: 28px;
	left: 160px;
}
.subbut button:HOVER{
	background: rgb(84,231,56);
}


label{color: #fff;}
#errormsg {
	color: red;
	font-size:13px;
	position: absolute; top: 290px;left: 225px;
}
</style>
</head>
<body>
	<div class="logingb">
		<div style="position: absolute; top: 150px;left: 160px;">
			<label>用户名：<input type="text" name="username" id="account" value="" maxlength="16"/> </label>
		</div>
		<div style="position: absolute; top: 200px;left: 160px;">
			<label> <script type="text/javascript">
				var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串  
				var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器  
				var isIE = userAgent.indexOf("compatible") > -1
						&& userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器  
				if (isIE) {
					document.write("密&nbsp;&nbsp;码：");

				} else {
					document.write("密&nbsp;码：");
				}
			</script> <input style="position: absolute;left:65px;top: 0px;" type="password" name="" id="password" value="" maxlength="20"/> </label>
		</div>
		<div class="subbut">
			<button id="loginmsubmit">登 录</button>
		</div>
		<div id="errormsg"></div>
	</div>
	<img alt="" src="images/login/登录1bg.jpg"
		style="position:absolute; top:0; left:0;" width="100%" height="100%">
</body>
<script type="text/javascript">
	$("#account").bind('input propertychange', function() {
		var checkuser = $("#account").val();
		if(checkuser.match(/(^\s+)|(\s+$)/g)){
			$("#account").val(checkuser.replace(/^\s\s*/, '').replace(/\s\s*$/, ''));
		}
		var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
		if(reg.test(checkuser)){
			$("#errormsg").html("用户名格式输入错误！");
		}
		if(checkuser.length > 16){
			$("#errormsg").html("用户名最大长度为16个字符！");
		}
    	if(checkuser.match(/^[\u2E80-\u9FFF]+$/)){
			$("#account").val("");
		}	
	});
	
	//$("#password").bind('input propertychange', function() {
	//	if($("#password").val().match(/(^\s+)|(\s+$)/g)){
	//		$("#password").val($("#password").val().replace(/^\s\s*/, '').replace(/\s\s*$/, ''));
	//	}
	//});
	/* $("#password").live("change",function(){
		var checkpwd = $("#password").val();
		if(!(checkpwd.match(/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$/))) {
			if(checkpwd.match(/^[\u2E80-\u9FFF]+$/)){
				//$("#password").val("");	
			}	
			$("#errormsg").html("密码输入格式错误。数字字母组合，6-20个字符！");
		}else if(checkpwd.length > 20){
			$("#errormsg").html("密码最大长度为20个字符！");
			$("#password").val(checkpwd.substring(0,20));
		}else{
			$("#errormsg").html("");
		}
	});  */
	
	$("#loginmsubmit").on("click",function(){
		$login.login();
	
	});
	$(window).keydown(function(e){
		if(e.keyCode == 13){
			$("#loginmsubmit").click();
		}
	});
	
	var $login = {
		getValue : function() {
			return {
				username : $("#account").val(),
				password : hex_sha1($("#password").val()),
				//password : $("#password").val(),
				code : $("#code").val()
			};
		},
		userNameCheck : function() {
			if ($login.getValue().username == "") {
				$("#errormsg").html("用户名不能为空！");
				return false;
			} else if (false) {
				$("#errormsg").html();
				return false;
			} else {
				return true;
			}
		},
		passwordCheck : function() {
			var pwd = $login.getValue().password;
			if (pwd == "") {
				$("#errormsg").html("密码不能为空！");
				return false;
			} /* else if(!pwd.match(/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$/)) {
				$("#errormsg").html("密码输入格式错误。数字字母组合，6-20个字符！");
				return false;
			} */ else {
				return true;
			}
		},
		/* codeCheck : function() {
			if ($login.getValue().code == "") {
				$("#errormsg").html("验证码不能为空");
				return false;
			} else if (!$login.getValue().code.match("^[0-9]{4}$")) {
				$("#vcode").attr("src", "user/code.do?r=" + Math.random());
				$("#errormsg").html("验证码错误");
				return false;
			} else {
				return true;
			}
		}, */
		login : function() {
			$login.getValue();
			if (!$login.userNameCheck()) return;
			if (!$login.passwordCheck()) return;
			//if (!$login.codeCheck()) return;
			var data = {
				account : $login.getValue().username,
				password : $login.getValue().password
				//code : $login.getValue().code
			};
			$.post("user/login.do?r=" + Math.random(), data, function(msg) {
				var d  = msg;
				if(d.rst){
					window.location.replace("<%=basePath%>"+"index.jsp");
					
				}
				else{
					$("#errormsg").text(d.msg);
				}
			});
		}
	};
</script>
</html>
